package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.DTO.operate.OperateDeviceWhiteListAuthRulesDTO;
import com.itlong.cloud.POJO.VO.operate.OperateDeviceWhiteListAuthRulesVO;
import com.itlong.cloud.equip.operate.IOperateDeviceWhiteListAuthRulesServiceClient;
import com.itlong.cloud.operate.service.IOperateDeviceWhiteListAuthRulesService;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <desc>
 *      运营-设备白名单授权文件规则管理暴露实现类
 * </desc>
 *
 * @createDate 2020/08/11
 **/
@RestController
public class OperateDeviceWhiteListAuthRulesServiceResource implements IOperateDeviceWhiteListAuthRulesServiceClient {

    @Autowired
    IOperateDeviceWhiteListAuthRulesService iOperateDeviceWhiteListAuthRulesService;

    /**
     * <desc>
     *      分页获取设备白名单授权文件规则信息
     * </desc>
     *
     * @param dto 设备白名单DTO
     * @return
     * @Author Juguang.S
     * @createDate  2020/08/11
     */
    @Override
    @RequestMapping(path = "/operate/device/whiteList/authRules/getWhiteListAuthRulesByPage",method = RequestMethod.POST)
    public Page<OperateDeviceWhiteListAuthRulesVO> getWhiteListAuthRulesByPage(@RequestBody OperateDeviceWhiteListAuthRulesDTO dto) throws Exception {
        return iOperateDeviceWhiteListAuthRulesService.getWhiteListAuthRulesByPage(dto);
    }

    /**
     * <desc>
     *      保存设备白名单授权文件规则信息
     * </desc>
     *
     * @param dto 设备白名单授权文件规则DTO
     * @return
     * @Author Juguang.S
     * @createDate  2020/08/11
     */
    @Override
    @RequestMapping(path = "/operate/device/whiteList/authRules/save",method = RequestMethod.POST)
    public void save(@RequestBody OperateDeviceWhiteListAuthRulesDTO dto) throws Exception {
        iOperateDeviceWhiteListAuthRulesService.save(dto);
    }

    /**
     * <desc>
     *      禁用启用设备白名单授权文件规则
     * </desc>
     *
     * @param dto 参数DTO
     * @return
     * @Author Juguang.S
     * @createDate  2020/08/11
     */
    @Override
    @RequestMapping(path = "/operate/device/whiteList/authRules/forbidden",method = RequestMethod.POST)
    public void forbidden(@RequestBody OperateDeviceWhiteListAuthRulesDTO dto) throws Exception {
        iOperateDeviceWhiteListAuthRulesService.forbidden(dto);
    }

    /**
     * <desc>
     * 根据授权规则id更新授权可用次数
     * </desc>
     *
     * @param dto
     * @Author chengshican
     * @Date 2020-08-16 9:31
     * @Param usedTimes 可用次数  ruleId规则id
     * @Return
     * @Exception
     */
    @RequestMapping(path = "/operate/device/whiteList/authRules/updateWhiteListAuthRulesByRuleId",method = RequestMethod.POST)
    @Override
    public int updateWhiteListAuthRulesByRuleId( @RequestBody OperateDeviceWhiteListAuthRulesDTO dto) throws Exception {
        return iOperateDeviceWhiteListAuthRulesService.updateWhiteListAuthRulesByRuleId(dto);
    }
    /**
     * <desc>
     * 根据输入的密码获取设备白名单授权文件规则信息集合
     * </desc>
     *
     * @param dto
     * @Author chengshican
     * @Date 2020-08-20 9:31
     * @Param
     * @Return
     * @Exception
     */
    @RequestMapping(path = "/operate/device/whiteList/authRules/getWhiteListAuthRulesByList",method = RequestMethod.POST)
    @Override
    public List<OperateDeviceWhiteListAuthRulesVO> getWhiteListAuthRulesByList(@RequestBody OperateDeviceWhiteListAuthRulesDTO dto) throws Exception {
        return iOperateDeviceWhiteListAuthRulesService.getWhiteListAuthRulesByList(dto);
    }

    /**
     * <desc>
     *      校验同一时间内的密码不能重复
     * </desc>
     *
     * @param dto 设备白名单授权文件规则DTO
     * @return
     * @Author Juguang.S
     * @createDate  2020/08/20
     */
    @Override
    @RequestMapping(path = "/operate/device/whiteList/authRules/checkPassword",method = RequestMethod.POST)
    public Integer checkPassword(@RequestBody OperateDeviceWhiteListAuthRulesDTO dto) throws Exception {
        return iOperateDeviceWhiteListAuthRulesService.checkPassword(dto);
    }


}
